package com.joe.xl.demo.thread.cyclibarrier;

import java.util.concurrent.CyclicBarrier;

public class Demo {

    public static void main(String[] args) {
        final CyclicBarrier cyclicBarrier = new CyclicBarrier(5, () -> {
            System.out.println("banchang xiuxi...");
        });

        Thread[] threads = new Thread[5];
        try {
            for (int i = 0; i < 5; i++) {
                A a = new A(i, cyclicBarrier);
                threads[i] = a;
            }

            for (int i = 0; i < 5; i++) {
                threads[i].start();
            }
        } catch (Exception e) {
            System.out.println("error...");
        }

        System.out.println("end...");
    }
}
